package com.ymy.eb.esaybuy.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ymy.eb.esaybuy.mapper.EbUserMapper;
import com.ymy.eb.esaybuy.model.EbUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service

public class EbUserServiceImpl implements EbUserService{
    @Autowired
    private EbUserMapper ebUserMapper;

    @Override
    public EbUser login(EbUser ebUser) {
        EbUser lgnUser = ebUserMapper.selectOne(Wrappers.<EbUser>lambdaQuery()
                .eq(EbUser::getEuUserId, ebUser.getEuUserId())
                .eq(EbUser::getEuPassword, ebUser.getEuPassword()));
        return lgnUser;
    }

    @Override
    public EbUser register(EbUser ebUser) {
        int result = ebUserMapper.insert(ebUser);
        if(result<=0){
            return null;
        }
        return ebUser;
    }
}